package gmomo;

import org.jivesoftware.smack.ChatManager;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet;

public class GMoMoConnection {
	
	private final static String RESOURCE = "sharedmind" ;
	
	private XMPPConnection connection;
	
	public GMoMoConnection(ConnectionConfiguration config) {
		connection = new XMPPConnection(config);
	}
	
	public void connect() throws Exception {
		connection.connect();
	}
	
	public boolean isConnected() {
		return connection.isConnected();
	}
	
	public void disconnect() {
		connection.disconnect();
	}
	
	public void login(String username, String password, String resource) throws Exception {
		connection.login(username, password, resource);
	}
	
	public void login(String username, String password) throws Exception {
		login(username, password, RESOURCE);
	}
	
	public boolean isAuthenticated() {
		return connection.isAuthenticated();
	}
	
	public void addPacketListener(PacketListener packetListener, PacketFilter packetFilter) {
		connection.addPacketListener(packetListener, packetFilter);
	}
	
	public void sendPacket(Packet packet) {
		connection.sendPacket(packet);
	}
	
	public ChatManager getChatManager() {
		return connection.getChatManager();
	}
}
